/**
 * 
 */
package com.aierkeji.b2c.utils;

import java.math.BigDecimal;

/**
 * @author garfieldying
 *
 */
public class PriceFormatter {

	private static int DEFAULT_DECIMAL_PLACE = 2;

	private static int DEFAULT_ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;

	/**
	 * Format the price with default decimal place (2) and round half up mode.
	 * @param value original double value
	 * @return scaled rounding decimal
	 */
	public static BigDecimal getDefaultRounding(BigDecimal value) {
		return value.setScale(DEFAULT_DECIMAL_PLACE, DEFAULT_ROUNDING_MODE);
	}

	/**
	 * Format the price with default decimal place (2) and round half up mode.
	 * @param value original double value
	 * @return scaled rounding decimal
	 */
	public static BigDecimal getDefaultRounding(double value) {
		return getDefaultRounding(new BigDecimal(value));
	}

	/**
	 * Format the price with default decimal place (2) and round half up mode.
	 * @param value original double value
	 * @return scaled rounding decimal
	 */
	public static double getDefaultRoundingDouble(double value) {
		return getDefaultRounding(value).doubleValue();
	}

	/**
	 * Private constructor.
	 */
	private PriceFormatter() {
	}
}
